/*
 * @Author: wurangkun
 * @Date: 2024-07-23 19:41:27
 * @LastEditTime: 2024-07-24 11:05:23
 * @LastEditors: wurangkun
 * @FilePath: \my-app\hooks\routerHooks.ts
 * @Description: 路由跳转方法
 */
import { ExpoRouter } from "@/.expo/types/router";
import { router } from "expo-router";

export const toHome = () => {
  // navigation.dispatch(StackActions.popToTop());
  relaunch('/')
}

export const toIndex = () => {
  router.dismissAll();
}

export const to = (href: ExpoRouter.Href) => {
  router.push(href)
}

export const replace = (href: ExpoRouter.Href) => {
  router.replace(href)
}

export const goBack = () => {
  router.back();
}

export const relaunch = (href: ExpoRouter.Href) => {
  try {
    toIndex()
    replace(href)
  } catch (error) {
    console.error(error)
  }
};